import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import AutoImport from 'unplugin-auto-import/vite'

export default defineConfig(async () => {
    const UnoCSS = (await import('unocss/vite')).default

    return {
        resolve: {
            alias: {
                '@': fileURLToPath(new URL('./src', import.meta.url))
            }
        },
        plugins: [
            // https://github.com/uni-helper/vite-plugin-uni-pages
            uni(),
            UnoCSS(),
            AutoImport({
                imports: ['vue', 'uni-app'],
                vueTemplate: true, // default false
            }),
        ],
        server: {
            port: 3333,
            host: true,
            open: true,
            proxy: {
                '/jjh': {
                    // target : "http://localhost:8088",
                    target : "http://47.96.248.83:7130", //线上地址
                    // "target": "http://192.168.1.85:7130",  //HJC有线
                    // "target": "http://192.168.10.168:8080", //HJC无线
                    // "target": "http://192.168.10.7:7130", //FLR无线
                    changeOrigin: true,
                    rewrite: (p) => p.replace(/^\/jjh/, '')
                }
            }
        },
    }
})



